#include "fx-parser/fxp.h"

using namespace std;
using namespace fxp;

/*
class State{
private:
    int z;
public:
    string name;
    double x;
    double y;
};
*/
class State{
public:
    string name;
    double x;
};


int main()
{
    bool ret;
    ParseErrorData ped;
    State s;   /* results here */
    
    FXParser<State> xmlX("X");
    add_attr(xmlX, "value", &State::x);
    FXParser<State> xmlState("State");
    //      add_child(xmlState, &State::x, xmlX);
    add_attr(xmlState, "id", &State::name);
    
    FXPRootParser<State> dataParser("State", xmlState);
    
    /* sino, si fuera una estructura comun, seria:
     *    FXPRootParser<ExecutionData> dataParser("data");
     *        add_child(dataParser, xmlGrupo, &ExecutionData::grupos);
     *        ignore_attr(dataParser, "ignore_me");
     */
    
    ret = parse_xml("SampleInput.xml", s, dataParser, ped, Warn, Warn);
    
    if (ret)
    {
        cout << s.name << endl;
        cout << s.x << endl;
    }
    else
    {
        cerr << "Error: " << ped.error << " at line " << ped.line << endl;
    }
    
    return 0;
}
